package org.crumbleworks.crumbcrane.crate;

import org.newdawn.slick.opengl.Texture;

public abstract class ArmedCrate extends Crate {
    protected int damagePoints, range;

    public ArmedCrate(float x, float y, float width, float height, float r, float g, float b, Texture texture, int hitPoints, int damageResistance, int damagePoints, int range) {
        super(x, y, width, height, r, g, b, texture, hitPoints, damageResistance);

        this.damagePoints = damagePoints;
        this.range = range;
    }

    /**
     * Attacks the passed Crate.
     * 
     * @param attackedCrate crate which is about to be attacked
     * @return true if attacked crate is destroyed, else false
     */
    public abstract boolean attack(Crate attackedCrate);

    /**
     * Checks if the passed Crate is in range of this ArmedCrate.
     * 
     * @return true if in range
     */
    public boolean isInRange(Crate crateToCheck) {
        if (crateToCheck.intersects(this.x - this.range, this.y - this.range, this.width + (2 * this.range), this.height + (2 * this.range))) {
            return true;
        }

        return false;
    }

    public int getDamagePoints() {
        return damagePoints;
    }

    public void setDamagePoints(int damagePoints) {
        this.damagePoints = damagePoints;
    }

    public int getRange() {
        return range;
    }

    public void setRange(int range) {
        this.range = range;
    }
}
